Skip to content

Moves back to using a List of AVars for the listeners #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2018

Conversation

kritzcreek
Copy link
Contributor

@kritzcreek kritzcreek commented Feb 15, 2018

We keep losing messages with the old implementation, even when using a buffered reader, so this is the previous implementation with only the updated to make it work on Aff 4.

Copy link
Member

@garyb garyb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess unless @natefaubion has any comments 👍 - I helped with this, so don't have anything to say 😄

kill err (Bus cell consumers) = do
killVar err cell
vars ← takeVar consumers
traverse_ (killVar err) vars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This used to kill consumers as well, but doing so propagated an error all the way up now, so we dropped that part. It'll be empty anyway, so I think it's still fine.

putVar mempty consumers
sequence_ (foldl (\xs a → putVar res a : xs) mempty vars)
loop
_ ← forkAff loop
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need to be an unsafe fork (liftEff <<< launchAff) unless you want to let users to control the lifecycle of the loop with supervised.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing that line to _ ← liftEff (launchAff (forkAff loop)) explodes the tests with:

/home/creek/work/purescript-aff-bus/output/Control.Monad.Aff/foreign.js:513
                throw util.fromLeft(step);
                ^

TypeError: bhead is not a function
    at run (/home/creek/work/purescript-aff-bus/output/Control.Monad.Aff/foreign.js:274:20)
    at Object.run (/home/creek/work/purescript-aff-bus/output/Control.Monad.Aff/foreign.js:623:13)
    at __do (/home/creek/work/purescript-aff-bus/output/Control.Monad.Aff/index.js:91:11)
    at runSync (/home/creek/work/purescript-aff-bus/output/Control.Monad.Aff/foreign.js:90:20)
    at run (/home/creek/work/purescript-aff-bus/output/Control.Monad.Aff/foreign.js:319:22)
    at /home/creek/work/purescript-aff-bus/output/Control.Monad.Aff/foreign.js:620:15
    at drain (/home/creek/work/purescript-aff-bus/output/Control.Monad.Aff/foreign.js:120:9)
    at Object.enqueue (/home/creek/work/purescript-aff-bus/output/Control.Monad.Aff/foreign.js:141:11)
    at Object.run (/home/creek/work/purescript-aff-bus/output/Control.Monad.Aff/foreign.js:619:23)
    at __do (/home/creek/work/purescript-aff-bus/output/Control.Monad.Aff/index.js:91:11)
* ERROR: Subcommand terminated with exit code 1

Looks like it's maybe a bug in Aff?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kritzcreek
Copy link
Contributor Author

So, I'm going to merge this because we're not using supervise on these Buses as of yet and it's blocking me. The error I'm getting looks like a failure in either AVar's or Aff's FFI, so maybe @natefaubion could take a look at them? Until then I've opened #7

@kritzcreek kritzcreek merged commit 3eb7a91 into master Feb 19, 2018
@garyb garyb deleted the fancy-new-old-bus branch April 25, 2018 18:36
safareli added a commit to safareli/purescript-aff-bus that referenced this pull request May 21, 2018
if `var` is killed with an error, `takeVar var` will throw that same error so the loop will be terminated.

note: before purescript-contrib#6 attempt  was not used
garyb pushed a commit that referenced this pull request Nov 26, 2018
* use tailRecM in make loopthis shuold avoid Memory leak #10

* no need for `attempt`

if `var` is killed with an error, `takeVar var` will throw that same error so the loop will be terminated.

note: before #6 attempt  was not used

* wrap forever with attempt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants